#!/bin/bash

. /etc/init.d/functions

if [ $# -ne 2 ] ; then
	echo "Usage: $0 { /local/path/to/file | /remote/path/to/dir }"
	exit 1
fi

for i in 199 200
do
	scp -r -P22 $1 lavenliu@192.168.56.${i}:~ &>/dev/null && \
	ssh -t lavenliu@192.168.56.${i} sudo rsync $1 $2 &>/dev/null
	if [ $? -ne 0 ] ; then
		action "fenfa $1 failure" /bin/false
	else
		action "fenfa $1 successful" /bin/true
	fi
done
